<template>
	<view class="app_Cont">
		<view class="showCont" v-if="showCont">
			<view class="navCont">
				<view class="navItem" @click="navFn(item)" :key="index" v-for="(item,index) in navArr">
					<view :class="navId==item.id?'navText navActive':'navText'">{{item.name}}</view>
					<image v-if="navId==item.id" class="navImg" src="/static/img/navImg.png"></image>
				</view>
			</view>
			<scroll-view class="workCont" scroll-y="true" @scrolltolower="scrolltolower" lower-threshold="10" >
				<view class="workItem"  :key="index" v-for="(item,index) in listArr">
					<view class="userImage">
						<image :src="item.head_img"></image>
					</view>
					<view class="workInfo">
						<view class="workHead">
							<view class="workName">{{item.nick_name}}</view>
							<view class="workMoney">
								<text class="blackText" v-if="item.is_ws==1">待完善简历</text>
								<text class="greenText" v-if="item.is_ws==2">推广成功</text>
							</view>
						</view>
						<view class="workDes">
							<view class="workPoints">
								<text class="iconfont icon-zcpt-jifenguanli"></text>
								<text>{{item.share_integral}}</text>
							</view>
							<view class="workTime">{{item.create_time}}</view>
						</view>
					</view>
				</view>
				<noData v-if="listArr.length==0&&!isChange"></noData>
				<loadMore v-if="!isChange&&last_page==page"></loadMore>
			</scroll-view>
		</view>
		<load v-if="!showCont||isChange"></load>
	</view>
</template>

<script>
	import api from '@/http/api.js'
	import load from '@/components/load.vue'
	import noData from '@/components/noData.vue'
	import loadMore from '@/components/loadMore.vue'
	export default {
		components:{load,noData,loadMore},
		data() {
			return {
				showCont:false,
				navArr:[
					{name:'全部记录',id:0},
					{name:'推广成功',id:2},
					{name:'简历待完善',id:1},
				],
				navId:0,
				page:1,
				per_page:10,
				last_page:0,
				listArr:[],
				isChange:false,
			};
		},
		methods:{
			scrolltolower(){
				if(this.page<this.last_page){
					this.page++
					this.isChange = true
					this.getData()
				}
			},
			navFn(item){
				this.navId = item.id
				this.serchFn()
			},
			serchFn(){
				this.page =1
				this.listArr = []
				this.isChange = true
				this.getData()
			},
			getData(){
				let data = {
					is_ws:this.navId,
					page:this.page,
					per_page:this.per_page,
				}
				api.getRequst(data,'/api/Integral/promotionRecord').then((res)=>{
					if(res.code==1){
						let arr = res.data.data
						for(let item of arr){
							this.listArr.push(item)
						}
						this.last_page = res.data.last_page
					}
					this.showCont = true
					this.isChange = false
				})
			}
		},
		onLoad() {
			this.getData()
		}
	}
</script>

<style lang="scss">
.showCont{
	height: 100vh;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
}
.navCont{
	width: 100%;
	padding: 80rpx 4% 30rpx;
	box-sizing: border-box;
	display: flex;
	justify-content: space-between;
	.navItem{
		width: 30%;
		text-align: center;
		position: relative;
		.navImg{
			position: absolute;
			height: 80rpx;
			width: 80rpx;
			left: 20rpx;
			top: -66rpx;
			transform: rotateY(180deg);
			z-index: 1;
		}
		.navText{
			width: 100%;
			border-radius: 50rpx;
			background-color: #fff;
			padding: 15rpx 0;
			position: relative;
			z-index: 2;
			color: #666;
			font-size: 26rpx;
		}
		.navActive{
			background-color: #3f55cc;
			color: #fff;
		}
	}
}

.workCont{
	width: 100%;
	height: 500rpx;
	flex: 1;
	padding: 30rpx 4% 30rpx;
	overflow-y: auto;
	box-sizing: border-box;
	.workItem{
		background-color: #fff;
		padding: 30rpx 4% 20rpx;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
		box-sizing: border-box;
		display: flex;
		.userImage{
			width: 100rpx;
			height: 100rpx;
			image{
				border-radius: 50%;
				width: 100%;
				height: 100%;
			}
		}
		.workInfo{
			flex: 1;
			width: 100rpx;
			margin-left: 30rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			.workHead{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.workName{
					width: 100rpx;
					font-size: 28rpx;
					font-weight: bold;
					flex: 1;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					margin-right: 30rpx;
				}
				.workMoney{
					font-size: 24rpx;
				}
			}
			.workDes{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.workPoints{
					display: flex;
					align-items: center;
					color: #3f55cc;
					font-size: 30rpx;
					.iconfont{
						margin-right: 10rpx;
					}
				}
				.workTime{
					font-size: 20rpx;
					color: #666;
				}
			}
		}
	}
}
</style>
